#define LG_CORE

#include "lg_init.h"
#include "lg_window.h"
#include "lg_texture.h"
#include "lg_draw.h"
#include "lg_vertex.h"
#include "lg_std.h"
#include "lg_canvas.h"
#include "lg_shader.h"


static struct {
	LGBackend* backend;
}gCtx = { 0 };

LG_API int
lgInit(LGConfig* config, LGBackend* backend){
	gCtx.backend = backend;
	lgInitRefContext(config);
	lgInitWindowContext(config, backend->window);
	lgInitTextureContext(config, backend->texture);
	lgInitDrawContext(config, backend->draw);
	lgInitShaderContext(config, backend->shader);
	lgInitCanvasContext(config, backend->canvas);
	lgInitVertexContext(config, backend->vertex);
	lgInitStdContext(config, backend->std);
	backend->init(config);
	return 0;
}

LG_API void
lgDefault(LGConfig* config){
}

LG_API int
lgDispatch() {
	lgAutoGcRef();
	gCtx.backend->dispatch();
	return 0;
}